<?php
class comment_model extends CI_Model
{
    protected $_table = "mock_comments";
    protected $_tableproduct = "mock_products";

    public function __construct(){
        parent::__construct();
    }

    public function totalComment(){
        return $this->db->count_all($this->_table);
    }

    public function listComment($off,$start){
        $this->db->limit($off,$start);
        return $this->db->get($this->_table)->result_array();
    }
    public function nameProduct(){
        return $this->db->get($this->_tableproduct)->result_array();
    }
    public function delete($id){
        $this->db->delete($this->_table,array('comment_id'=>$id));
    }
    public function updateShow($id){
        $this->db->query("UPDATE mock_comments
SET comment_show = IF(comment_show = 0,1,IF(comment_show = 1,0,0)) WHERE comment_show IS NOT NULL and comment_id = '$id'");
    }
    public function getdata($id){
        $this->db->where("comment_id",$id);
        return $this->db->get($this->_table)->row_array();
    }
}